import { API_CONFIG } from '../config/apiConfig';

export const GetFriendList = () => {
  return fetch(`${API_CONFIG.HOST}/friend/GetFriendList?key=${API_CONFIG.KEY}`)
    .then(response => {
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
      return response.json();
    })
    .then(data => {
      if (data.Code !== 200) {
        throw new Error(`API error! code: ${data.Code}`);
      }
      return data.Data.friendList;
    })
    .catch(error => {
      console.error('获取好友列表失败:', error);
      throw error;
    });
};